package com.atguigu.gmall.product.rpc;

import com.atguigu.gmall.model.product.SkuInfo;
import com.atguigu.gmall.product.service.SkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/8/29 23:52
 */
@RestController
@RequestMapping("/rpc/inner/product")
public class RpcSkuController {
    @Autowired
    private SkuInfoService skuInfoService;
    @GetMapping("/skuInfo/{skuId}")
    SkuInfo getSkuInfo(@PathVariable("skuId") Long skuId){
      return   skuInfoService.getDetailById(skuId);
    }

    @GetMapping("/skuInfoPrice/{skuId}")
    BigDecimal getSkuInfoPrice(@PathVariable("skuId") Long skuId){
        return skuInfoService.getSalePrice(skuId);
    }

    //获取valueJson数据{"115|117":44,"116|118":45}
    @GetMapping("/valueJson/{skuId}")
    String getValueJson(@PathVariable("skuId") Long skuId){
        return skuInfoService.getValueJson(skuId);
    }
}
